﻿#ifdef _WIN32
#include "windows_defines.h"
#endif

#include "../../../../../../unittest/framework/unittest.hh"
#include "util/util_impl.hh"
#include "box/service_box.hh"
#include "box/service_context.hh"
#include "detail/service_context_impl.hh"
#include "fwd.h"
#include <vector>
#include <string>

FIXTURE_BEGIN(test_util)

SETUP([]() {
})

CASE(TestUtil1) {
    auto util_ptr = std::unique_ptr<kratos::service::UtilImpl>(
      new kratos::service::UtilImpl());
    ASSERT_TRUE(util_ptr != nullptr);
    
    //std::string split_str = "guild:1001";
    std::vector<std::string> split_result;

    util_ptr->splitBy(std::string("guild:1001"), ':', split_result);
    ASSERT_TRUE(split_result.size() == 2);

    std::cout << split_result[0] << " " << split_result[1] << '\n';

    ASSERT_TRUE(split_result[0] == "guild:");
    ASSERT_TRUE(split_result[1] == "1001");
}

CASE(TestUtil2) {
    kratos::service::ServiceContext * context = new kratos::service::ServiceContextImpl(nullptr);
    guild_service::common::singleton_start<guild_service::common::util>(context);
    std::cout << "stack_trace:" << UtilSingleton()->get_current_stack_trace_info(10) << '\n';
    guild_service::common::singleton_stop<guild_service::common::util>();
    delete context;
}

FIXTURE_END(test_util)